package com.qqtech.qquan.mall.service;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;

import com.qqtech.core.frame.dao.BaseDao;
import com.qqtech.core.frame.model.PageKit;
import com.qqtech.core.frame.model.PageOrder;
import com.qqtech.core.frame.service.BaseServiceImpl;
import com.qqtech.qquan.mall.dao.MallSupplierDao;
import com.qqtech.qquan.mall.model.MallSupplier;
import com.qqtech.qquan.mall.model.MallSupplierQuery;
import com.qqtech.qquan.mall.model.MallSupplierVo;

@Service
public class MallSupplierServiceImpl extends BaseServiceImpl<MallSupplier>
		implements MallSupplierService {
	public static final Logger log = LoggerFactory.getLogger(MallSupplierServiceImpl.class);
	
	@Resource
	private MallSupplierDao mallSupplierDao;

	@Override
	protected BaseDao<MallSupplier> getBaseDao() {
		return mallSupplierDao;
	}

	/**
	 * 根据状态获取供应商
	 * @param status 状态,当status==null时,返回所有状态的
	 * @return
	 */
	@Override
	public List<MallSupplierVo> getByStatus(Integer status) {
		MallSupplierQuery q = new MallSupplierQuery();
		q.setStatus(status);
		Pageable pageKit = new PageKit(1, 9999,
				new PageOrder(Direction.ASC, "firstLetter"));
		List<MallSupplierVo> list = mallSupplierDao.queryList(q, pageKit);
		return list;
	}

	@Override
	public MallSupplierVo getByName(String name) {
		return mallSupplierDao.getByName(name);
	}
	
}